#include "friend.h"

Friend::Friend() {}

Friend::Friend(const Friend &f) {
    this->f_name = f.f_name;
    this->f_sid = f.f_sid;
    this->f_state = f.f_state;
    this->f_host = f.f_host;
}

Friend& Friend::operator=(const Friend& f) {
    this->f_name = f.f_name;
    this->f_sid = f.f_sid;
    this->f_state = f.f_state;
    this->f_host = f.f_host;
    return *this;
}

bool Friend::operator<(const Friend& right) {
    if (this->f_state == 1 && right.f_state == 1) {
        return this->name() < right.f_name;
    } else if (right.f_state == 1) {
        return false;
    } else if (this->f_state == 1) {
        return true;
    } else {
        return this->name() < right.f_name;
    }
}

QString Friend::name() {
    return this->f_name;
}
void Friend::setName(QString name) {
    this->f_name = name;
    emit this->nameChanged();
}

long Friend::sid() {
    return this->f_sid;
}
void Friend::setSid(qlonglong sid) {
    this->f_sid = sid;
    emit this->sidChanged();
}

int Friend::state() {
    return this->f_state;
}
void Friend::setState(int state) {
    this->f_state = state;
    emit this->stateChanged();
}

int Friend::host() {
    return this->f_host;
}
void Friend::setHost(int host) {
    this->f_host = host;
    emit this->hostChanged();
}
